package tq.com.tqstudent.ui.activity.mine;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.LinearLayout;

import com.just.agentweb.AgentWeb;
import com.lib.common.base.BaseActivity;

import butterknife.BindView;
import tq.com.tqstudent.R;

/**
 * @Author rames
 * @date 2019/4/16 22:25
 */
public class ProtocolActivity extends BaseActivity {
    @BindView(R.id.layout)
    LinearLayout layout;
    private AgentWeb agentWeb;

    public static void show(Activity activity){
        Intent intent = new Intent(activity, ProtocolActivity.class);
        Bundle bundle = new Bundle();
        intent.putExtras(bundle);
        activity.startActivity(intent);
    }

    @Override
    public int initLayout() {
        return R.layout.activity_protocol;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        setTitle("服务协议");
        agentWeb= AgentWeb.with(this)
                .setAgentWebParent(layout, new LinearLayout.LayoutParams(-1, -1))
                .useDefaultIndicator()//进度条
                .createAgentWeb()
                .ready()
                .go("file:///android_asset/protocol.html");
    }

    @Override
    public void initData() {

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (agentWeb.handleKeyEvent(keyCode, event)) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


    @Override
    protected void onPause() {
        agentWeb.getWebLifeCycle().onPause();
        super.onPause();

    }

    @Override
    protected void onResume() {
        agentWeb.getWebLifeCycle().onResume();
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        agentWeb.getWebLifeCycle().onDestroy();
        super.onDestroy();
    }
}
